using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using THANHTUNGO.Portal.Components.UI;

namespace THANHTUNGO.Portal.Modules.DISCUSSION
{
    public partial class Main : PortalModuleControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                dlTopLevel.DataSource = Components.Item.GetTopLevel(this.ModuleID);
                dlTopLevel.DataBind();
            }
        }

        protected DataSet GetThreadMessages()
        {
            return Components.Item.GetThreadMessages(Convert.ToInt32(dlTopLevel.DataKeys[dlTopLevel.SelectedIndex].ToString()), 'Y');
        }
       
        protected void dlTopLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataList datalist = (DataList)dlTopLevel.Items[dlTopLevel.SelectedIndex].FindControl("DetailList");
            datalist.DataSource = GetThreadMessages();
            datalist.DataBind();

            dlTopLevel.DataSource = Components.Item.GetTopLevel(this.ModuleID);
            dlTopLevel.DataBind();

        }
    }
}